home *** CD-ROM | disk | FTP | other *** search
/ Total Web Page (Professional Suite) / Total Web Page 99.iso / CGI / DOWNLOAD.CGI-S=SSI_IMAGE&C=TXT&F=SSI_RAND_IMAGE.PL < prev    next >
Perl Script  |  1996-06-03  |  3KB  |  81 lines

  1. #!/usr/bin/perl
  2. ##############################################################################
  3. # SSI Random Image Displayer    Version 1.2                                  # 
  4. # Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
  5. # Created 7/1/95                Last Modified 11/4/95                        #
  6. # Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
  7. ##############################################################################
  8. # COPYRIGHT NOTICE                                                           #
  9. # Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
  10. #                                                                            #
  11. # SSI Random Image may be used and modified free of charge by anyone so      #
  12. # long as this copyright notice and the comments above remain intact.  By    #
  13. # using this this code you agree to indemnify Matthew M. Wright from any     #
  14. # liability that might arise from it's use.                                  #  
  15. #                                                                            #
  16. # Selling the code for this program without prior written consent is         #
  17. # expressly forbidden.  In other words, please ask first before you try and  #
  18. # make money off of my program.                                              #
  19. #                                                                            #
  20. # Obtain permission before redistributing this software over the Internet or #
  21. # in any other medium.  In all cases copyright and header must remain intact.#
  22. ##############################################################################
  23. # Define Variables
  24.  
  25. $basedir = "http://your.host.xxx/path/to/images/";
  26.  
  27. @images = ("first_image.gif","second_image.jpg","third_image.gif");
  28.  
  29. @urls = ("http://url_linked/to/first_image",
  30.          "http://url_linked/to/second_image",
  31.          "http://url_linked/to/third_image");
  32.  
  33. @alt = ("First WWW Page","Second WWW Page","Third WWW Page");
  34.  
  35. ##############################################################################
  36. # Options
  37. $uselog = "1";            # 1 = YES; 0 = NO
  38.    $logfile = "/path/to/log/file";
  39.    $date = `/usr/bin/date`; chop($date);
  40.  
  41. $link_image = "1";        # 1 = YES; 0 = NO
  42. $align = "left";
  43. $border = "2";
  44.  
  45. # Done
  46. ##############################################################################
  47.  
  48. srand(time ^ $$);
  49. $num = rand(@images); # Pick a Random Number
  50.  
  51. # Print Out Header With Random Filename and Base Directory
  52. print "Content-type: text/html\n\n";
  53. if ($link_image eq '1' && $urls[$num] ne "") {
  54.    print "<a href=\"$urls[$num]\">";
  55. }
  56.  
  57. print "<img src=\"$basedir$images[$num]\"";
  58. if ($border ne "") {
  59.    print " border=$border";
  60. }
  61. if ($align ne "") {
  62.    print " align=$align";
  63. }
  64. if ($alt[$num] ne "") {
  65.    print " alt=\"$alt[$num]\"";
  66. }
  67. print ">";
  68.  
  69. if ($link_image eq '1' && $urls[$num] ne "") {
  70.    print "</a>";
  71. }
  72.  
  73. print "\n";
  74.  
  75. # If You want a log, we add to it here.
  76. if ($uselog eq '1') {
  77.    open(LOG, ">>$logfile");
  78.    print LOG "$images[$num] - $date - $ENV{'REMOTE_HOST'}\n";
  79.    close(LOG);
  80. }
  81.